FROM artifact.enflame.cn/enflame_docker_images/ubuntu/qic_ubuntu_1804_gcc7:1.4.3

RUN rm -f /usr/bin/python \
 && rm -f /usr/bin/python3 \
 && rm -f /usr/bin/python-config \
 && rm -f /usr/bin/python3-config \
 && ln -s /usr/local/bin/python3.10 /usr/bin/python \
 && ln -s /usr/local/bin/python3.10 /usr/bin/python3 \
 && ln -s /usr/local/bin/python3.10-config /usr/bin/python-config \
 && ln -s /usr/local/bin/python3.10-config /usr/bin/python3-config

RUN apt update -y



RUN wget -c -O topsrider.run "http://mirrors.uat.enflame.cc/enflame.cn/maas/yaowen/1.1/TopsRider_i2x_2.5.105_deb_amd64.run" && \
    chmod +x topsrider.run && \
    ./topsrider.run -x && \
    dpkg -i TopsRider_i2x_*_deb*amd64/sdk/tops-sdk_*_amd64*.deb \
            TopsRider_i2x_*_deb*amd64/sdk/topsruntime_*_amd64.deb \
            TopsRider_i2x_*_deb*amd64/distributed/tops-eccl_*_amd64.deb \
            TopsRider_i2x_*_deb*amd64/framework/tops-inference_*_amd64*.deb && \
    pip3.8 install TopsRider_i2x_*_deb*amd64/framework/TopsInference-*.whl && \
    rm -f topsrider.run && \
    rm -fr TopsRider_i2x_*_deb*amd64 && \
    rm -rf topsinstaller

WORKDIR /code-server

RUN wget "https://github.com/coder/code-server/releases/download/v4.0.0/code-server-4.0.0-linux-amd64.tar.gz" && tar -xvzf code-server-gcu-4.0.0-linux-amd64.tar.gz

RUN wget --user sse_ard_uploader --password Admin@2022 http://artifact.enflame.cn/artifactory/onnxruntime_release/x86_64/python310/onnxruntime_gcu-1.9.1-2.5.20231106-cp310-cp310-linux_x86_64.whl && \
    pip3.10 uninstall onnxruntime -y && \
    pip3.10 install onnxruntime_gcu-1.9.1-2.5.20231106-cp310-cp310-linux_x86_64.whl

ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/tops/lib"
ENV EFRT_CLUSTER_AS_DEVICE=true
ENV ECCL_RUNTIME_3_0_ENABLE=true

ENTRYPOINT []
CMD ["./code-server-4.0.0-linux-amd64/bin/code-server",
    "--port","8082",
    "--host", "0.0.0.0",
    "--extensions-dir",
    "/root/.code-server-extension/",
    "/root/"]
